<!-- goodsList -->
<template>
  <div class="goods-list">
    <goods-list-item
      class="goods"
      v-for="(item, index) in list"
      :key="index"
      :goods="item"
      @click.native="goodsItemClick(item)"
    ></goods-list-item>

    <goods-list-item
      class="goods"
      v-if="list.length % 2 != 0"
      style="height: 0;"
    ></goods-list-item>
  </div>
</template>

<script>
import GoodsListItem from "./GoodsListItem";
export default {
  name: "GoodsList",
  props: {
    list: {
      type: Array,
      default() {
        return [];
      }
    }
  },
  data() {
    return {};
  },
  components: {
    GoodsListItem
  },
  methods: {
    goodsItemClick(goods) {
      this.$emit("goodsItemClick", goods);
    }
  }
};
</script>

<style scoped>
.goods-list {
  /* padding: 4px; */
  display: flex;
  justify-content: space-evenly;
  align-content: space-around;
  flex-wrap: wrap;
}
.goods {
  margin: 8px 0;
  width: 46%;
}
</style>
